<template>
	<!-- 其他设置 -->
	<div class="page-wrap">
		<div class="page-content p-0">
			<div class="page-column p-0">
				<div class="page-form p-x-0">
					<el-form
						:model="ruleForm"
						:rules="rules"
						label-position="left"
						label-width="170px"
						ref="form"
						label-suffix="："
					>
						<el-row>
							<el-col :span="24">
								<div class="my_title m-b-20">源项设置</div>
								<el-form-item label="源项名称" prop="RDATNAM2001">
									<el-input size="medium" class="mediumForm" v-model="ruleForm.RDATNAM2001"></el-input>
								</el-form-item>
							</el-col>
						</el-row>
						<div class="separate m-b-20"></div>
						<!-- <el-row>
							<el-col :span="24">
								<div class="my_title m-b-20">早期计算设置</div>
								<el-form-item label="是否跳过早期长期计算" prop="OCENDAT1001">
									<select-para
										style="width:100%"
										size="medium"
										class="mediumForm"
										v-model="ruleForm.OCENDAT1001"
										:label.sync="ruleForm.OCENDAT1001"
										:options="options"
									></select-para>
								</el-form-item>
							</el-col>
						</el-row> -->
					</el-form>
				</div>
				<div class="bottom-btn">
					<el-button type="primary" :loading="loading" @click="submitFun">提交</el-button>
				</div>
			</div>
		</div>
	</div>
</template>

<script>
import selectPara from "@/components/selectPara"
import commCheckbox from "@/components/commCheckbox"
import ImageCropper from "@/components/ImageCropper"
import FixBottomButton from "@/components/FixBottomButton"
import ueditor from "@/components/ueditor"
import textLength from "@/components/common/comp/textLength"
import { commPara } from "@/mixins/mixins"
import { mapState } from "vuex"

import { BATCH_SUBMIT } from "@/service/hd5.js"

export default {
	name: "aboutUs",
	props: {
		batchid: String,
	},
	mixins: [commPara],
	components: {
		selectPara,
		ImageCropper,
		textLength,
		commCheckbox,
		FixBottomButton,
		ueditor,
	},

	data() {
		return {
			activeTab: "9",
			ruleForm: {
				RDATNAM2001: "",
				OCENDAT1001: "FALSE",
			},
			rules: {
				RDATNAM2001: [
					{
						required: true,
						message: "名称必填",
						trigger: ["change", "blur"],
					},
					{
						min: 0,
						max: 80,
						message: "长度限制80位",
						trigger: ["change", "blur"],
					},
				],
			},
			options: [
				{
					label: "TRUE",
					value: "TRUE",
				},
				{
					label: "FALSE",
					value: "FALSE",
				},
			],
			loading: false,
			caidantype:1
		}
	},
	computed: {
		...mapState({
			basic_Data: (state) => state.token.basic_Data,
		}),
	},
	created(){
		this.caidantype=this.$route.query.caidantype
	},
	mounted() {
		this.setData()
	},
	methods: {
		setData() {
			this.ruleForm.RDATNAM2001 = this.basic_Data.RDATNAM2001
			this.ruleForm.OCENDAT1001 = this.basic_Data.OCENDAT1001
		},
		submitFun() {
			this.$refs.form.validate((valid) => {
				if (valid) {
					let template = JSON.parse(JSON.stringify(this.basic_Data))
					template.RDATNAM2001 = this.ruleForm.RDATNAM2001
					if(this.caidantype==1){
						template.OCENDAT1001 = 'TRUE'
					}else{
						template.OCENDAT1001 = 'FALSE'
					}
					
					template.SETPAGEINDEX = this.activeTab
					this.$store.dispatch("upData_basic_Data", template)
					let params = {
						batchid: this.$props.batchid,
						batchinfo: "BASE",
						submitjson: JSON.stringify(template),
					}
					this.$appApi
						.BATCH_SUBMIT(params)
						.then((res) => {
							var str = res.data.substring(0, 1)
							if (str == "E") {
								let message = res.data.substring(6)
								this.$notify.error({
									title: "提交失败！",
									message: message,
									type: "success",
								})
							} else if (str == "S") {
								this.$notify({
									message: "提交成功！",
									type: "success",
								})
								this.$router.push({
									path: "/home",
								})
							}
						})
						.catch((err) => {
							console.log(err)
						})
				}
			})
		},
	},
}
</script>
<style lang="scss" scoped>
.page-flex-row /deep/ .el-collapse-item__header {
	background: #f3f9fe;
}
</style>